package cn.wolfcode.service.impl;

import cn.wolfcode.domain.SystemDictionaryItem;
import cn.wolfcode.mapper.SystemDictionaryItemMapper;
import cn.wolfcode.qo.QueryObject;
import cn.wolfcode.service.ISystemDictionaryItemService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class SystemDictionaryItemServiceImpl implements ISystemDictionaryItemService {
    @Autowired
    private SystemDictionaryItemMapper systemDictionaryItemMapper;
    @Transactional
    public PageInfo<SystemDictionaryItem> selectForList(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        List<SystemDictionaryItem> systemDictionaryItems  = systemDictionaryItemMapper.selectForList(qo);
        return new PageInfo<>(systemDictionaryItems);
    }

    //查询上级明细显示在新增和编辑模态框中
    public List<SystemDictionaryItem> selectSuperiordetails() {
        List<SystemDictionaryItem> systemDictionaryItems = systemDictionaryItemMapper.selectSuperiordetails();

        return systemDictionaryItems;
    }

    @Override
    public List<SystemDictionaryItem> selectByTypeId(Long id) {
        return systemDictionaryItemMapper.selectByTypeId(id);
    }

    @Override
    public List<SystemDictionaryItem> selectByTypeSn(String sn) {
        List<SystemDictionaryItem> systemDictionaryItems = systemDictionaryItemMapper.selectByTypeSn(sn);
        return systemDictionaryItems;
    }

    //查询所有的业务大类
    public List<SystemDictionaryItem> selectAll() {
        List<SystemDictionaryItem> systemDictionaryItems = systemDictionaryItemMapper.selectAll();
        return systemDictionaryItems;
    }

    @Override
    public List<SystemDictionaryItem> selectByParentId(Long parentId) {
        List<SystemDictionaryItem> SystemDictionaryItems = systemDictionaryItemMapper.selectByPrentId(parentId);
        return SystemDictionaryItems;
    }
}
